package com.example.demo.demos.listener;

import com.example.demo.demos.test.MyBootStrapRegistry;
import com.example.demo.demos.test.MyBootStrapRegistry2;
import org.springframework.boot.ConfigurableBootstrapContext;
import org.springframework.boot.context.event.ApplicationStartingEvent;
import org.springframework.context.ApplicationListener;

public class MyBootStrapContextListener implements ApplicationListener<ApplicationStartingEvent> {


    @Override
    public void onApplicationEvent(ApplicationStartingEvent event) {
        System.out.println("SpringBoot容器启动，获取bootstrapContext");
        ConfigurableBootstrapContext bootstrapContext = event.getBootstrapContext();
        bootstrapContext.get(MyBootStrapRegistry.class).say();
        bootstrapContext.get(MyBootStrapRegistry2.class).say();
    }
}
